@extends("admin.layout.main")

@section("content")

    <style>
        table thead tr th {
            text-align: center
        }

        table tbody tr td {
            text-align: center
        }
    </style>
    <div class="page-header">
        <h1>
            权限模块管理
        </h1>
    </div>
    <div class="page-header">
        <form action="" method="get">
            <a href="{{ route('admin.platform.addModule') }}" class="btn btn-xs btn-primary">新增</a>
            <div style="float: right;">
                一级模块名称：
                <input type="text" name="keyword" value="{{ $where['keyword'] }}" placeholder="" style="height: 30px;">
                <button class="btn btn-xs btn-primary" type="submit" style="margin-top: -4px;">搜索</button>
            </div>
        </form>
    </div>

    <!-- div.dataTables_borderWrap -->
    <div>
        <table id="" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>ID</th>
                <th>模块名</th>
                <th>CODE</th>
                <th>上级ID</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            @foreach($data as $v)
                <tr>
                    <td>{{ $v->id }}</td>
                    <td style="color: green;">{{ $v->name }}</td>
                    <td>{{ $v->action_code }}</td>
                    <td>{{ $v->parent_id }}</td>
                    <td style="text-align: center">
                        <div class="hidden-sm hidden-xs action-buttons">
                            <a class="btn btn-xs btn-primary"
                               href="{{ route('admin.platform.editModule',['id'=>$v->id]) }}">
                                编辑
                            </a>
                            <a class="btn btn-xs btn-danger" data-id="{{ $v->id }}"
                               onclick="confirm_handle('确认删除吗？',del,'',this)">
                                删除
                            </a>
                        </div>
                        <div class="hidden-md hidden-lg">
                            <div class="inline pos-rel">
                                <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
                                        data-position="auto">
                                    <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                </button>

                                <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                    <li>
                                        <a href="{{ route('admin.platform.editModule',['id'=>$v->id]) }}"
                                           class="tooltip-info" data-rel="tooltip" title="编辑">
                                            <span class="blue">
                                               编辑
                                            </span>
                                        </a>
                                    </li>
                                    <li>
                                        <a data-id="{{ $v->id }}" onclick="confirm_handle('确认删除吗？',del,'',this)"
                                           class="tooltip-info" data-rel="tooltip" title="删除">
                                            <span class="red">
                                               删除
                                            </span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>
                @foreach($v->children as $cv)
                    <tr>
                        <td>{{ $cv->id }}</td>
                        <td style="color: orange">└ {{ $cv->name }}</td>
                        <td>{{ $cv->action_code }}</td>
                        <td>{{ $cv->parent_id }}</td>
                        <td style="text-align: center">
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="btn btn-xs btn-primary"
                                   href="{{ route('admin.platform.editModule',['id'=>$cv->id]) }}">
                                    编辑
                                </a>
                                <a class="btn btn-xs btn-danger" data-id="{{ $cv->id }}"
                                   onclick="confirm_handle('确认删除吗？',del,'',this)">
                                    删除
                                </a>
                            </div>
                            <div class="hidden-md hidden-lg">
                                <div class="inline pos-rel">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
                                            data-position="auto">
                                        <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="{{ route('admin.platform.editModule',['id'=>$cv->id]) }}"
                                               class="tooltip-info" data-rel="tooltip" title="编辑">
                                            <span class="blue">
                                               编辑
                                            </span>
                                            </a>
                                        </li>
                                        <li>
                                            <a data-id="{{ $cv->id }}" onclick="confirm_handle('确认删除吗？',del,'',this)"
                                               class="tooltip-info" data-rel="tooltip" title="删除">
                                            <span class="blue">
                                               删除
                                            </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                    @foreach($cv->children as $cv2)
                        <tr>
                            <td>{{ $cv2->id }}</td>
                            <td>└└ {{ $cv2->name }}</td>
                            <td>{{ $cv2->action_code }}</td>
                            <td>{{ $cv2->parent_id }}</td>
                            <td style="text-align: center">
                                <div class="hidden-sm hidden-xs action-buttons">
                                    <a class="btn btn-xs btn-primary"
                                       href="{{ route('admin.platform.editModule',['id'=>$cv2->id]) }}">
                                        编辑
                                    </a>
                                    <a class="btn btn-xs btn-danger" data-id="{{ $cv2->id }}"
                                       onclick="confirm_handle('确认删除吗？',del,'',this)">
                                        删除
                                    </a>
                                </div>
                                <div class="hidden-md hidden-lg">
                                    <div class="inline pos-rel">
                                        <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
                                                data-position="auto">
                                            <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                        </button>
                                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                            <li>
                                                <a href="{{ route('admin.platform.editModule',['id'=>$cv2->id]) }}"
                                                   class="tooltip-info" data-rel="tooltip" title="编辑">
                                            <span class="blue">
                                               编辑
                                            </span>
                                                </a>
                                            </li>
                                            <li>
                                                <a data-id="{{ $cv2->id }}" onclick="confirm_handle('确认删除吗？',del,'',this)"
                                                   class="tooltip-info" data-rel="tooltip" title="删除">
                                            <span class="blue">
                                               删除
                                            </span>
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                @endforeach
            @endforeach
            </tbody>
        </table>
    </div>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function del(obj) {
            var id = $(obj).data("id");
            var data = {'id': id};
            var url = '{{ route('admin.platform.delModule') }}';
            ajaxRequest(data, url, 'post');
        }
    </script>
@endsection